package com.example.myapplication;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button btnChat = findViewById(R.id.btn_chat);
        Button btnContacts = findViewById(R.id.btn_contacts);
        Button btnMusic = findViewById(R.id.btn_music);
        Button btnSettings = findViewById(R.id.btn_settings);

        btnChat.setOnClickListener(v -> loadFragment(new ChatFragment()));
        btnContacts.setOnClickListener(v -> loadFragment(new ContactsFragment()));
        btnMusic.setOnClickListener(v -> loadFragment(new MusicFragment()));
        btnSettings.setOnClickListener(v -> loadFragment(new SettingsFragment()));

        // Load default fragment
        if (savedInstanceState == null) {
            loadFragment(new ChatFragment());
        }
    }

    private void loadFragment(Fragment fragment) {
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.fragment_container, fragment)
                .commit();
    }
}